<?php

require_once 'class.remittance.php';
require_once 'class.sender.php';

$Remittance = new Remittance();
$Sender = new Sender();

if (isset($_GET['CL'])) {
    $ValidationResult = $Sender->ValidateSenderData($_POST);
    if (is_array($ValidationResult)) {
        if($_POST['CliNumero']==0){
        $Result = $Sender->NewSender($_POST['CliNumero'], $ValidationResult);
        } elseif($_POST['CliNumero']>0){
        $Result = $Sender->EditSender($_POST['CliNumero'], $ValidationResult);
        }
    } else {
        $Result = $ValidationResult;
    }
} elseif (isset($_GET['CL_BK'])) {
    $Result = $Sender->BlockSender($_POST);
    echo '<div class="Confirm">Concluido.</div>';
} elseif (isset($_GET['CL_DB'])) {
    $Result = $Sender->MergeSender($_POST);
    $prStr = "Ext.getCmp('win_dupcl').close();";
} elseif (isset($_GET['OR_BK'])) {
    $Result = $Remittance->BlockRemittance($_POST);
} elseif (isset($_GET['OR_CH'])) {
    if (!isset($_POST['sch_Information'])) {
        $_POST['sch_Information'] = 'Anulação sem motivo';
    }
    $Result = $Remittance->CancelRemittance($_POST['FraID'], $_POST['cnl_Type'], $_POST['FraStatus'], $_POST['sch_Information']);
} elseif (isset($_GET['ORST'])) {
    $Result = $Remittance->ActionRemittance($_POST['FraID'], $_GET['Flg'], $_POST['FraStatus'], req_form($_POST['edg_Motivo']));
} elseif (isset($_GET['OR'])) {
    if ($_GET['OR'] == 0) {
        #$Result = $Remittance->NewRemittance($_POST);
    } else {
        $Result = $Remittance->EditRemittance($_POST);
    }
} elseif (isset($_GET['DP'])) {
    include('prc_DP.mex');
} elseif (isset($_GET['DC'])) {
    include('prc_DC.mex');
} elseif (isset($_GET['RC'])) {
    include('prc_RC.mex');
} elseif (isset($_GET['AC'])) {
    include('prc_AC.mex');
}
if (!isset($prStr)) {
    $prStr = '';
}
if (!isset($Result) && isset($Msg_ERROR)) {
    $Result = $Msg_ERROR;
} elseif (!isset($Result)) {
    $Result = $qr_OBJ;
}
    if ($Result < 1) {
        $prStr = 'if(Ext.onReady(function(){
		Ext.getCmp(\'win-statusbar\').setStatus({text: \'<div class="Error">ERRO: ' . $Result . '</div>\'});
		})==false){
                alert(\''.$Result.'\');
                }';
    } else {
        $prStr = '/*document.pp_frm.' . $_GET['OBJ'] . '.value=' . $Result . ';*/
		Ext.onReady(function(){
		Ext.getCmp(\'win-statusbar\').setStatus({text: \'Pronto\'});
		});';
    }
echo '<script type="text/javascript">' . $prStr . '</script>';
?>
